import time
from common_utils import Model

class Release_Page:
    po = Model()

    def release_TW_1(self):
        # 发布1张图片
        self.po.poco("com.tencent.apps.valorant:id/bottom_title_center_btn").click()
        self.po.poco("com.tencent.apps.valorant:id/tvCheck").click()
        self.po.poco("com.tencent.apps.valorant:id/auxiliary_button").click()
        self.po.poco("com.tencent.apps.valorant:id/edit_title", text="添加标题可以让更多人看到哦").set_text("明天你好")
        self.po.poco("com.tencent.apps.valorant:id/edit_body", text="添加描述").set_text("要相信美好的事件即将发送")
        self.po.poco("com.tencent.apps.valorant:id/topic").click()
        self.po.poco("com.tencent.apps.valorant:id/option_layout").click()
        self.po.poco("com.tencent.apps.valorant:id/completed").click()
        time.sleep(1)

    def release_TW_9(self):
        # 发布9张图片
        self.po.poco("com.tencent.apps.valorant:id/bottom_title_center_btn").click()
        element = self.po.poco("com.tencent.apps.valorant:id/tvCheck")
        n = 9
        for i in range(n):
            element.click()
        print(f"已加入{i} 张")
        self.po.poco("com.tencent.apps.valorant:id/auxiliary_button").click()
        self.po.poco("com.tencent.apps.valorant:id/edit_title", text="添加标题可以让更多人看到哦").set_text("明天你好")
        self.po.poco("com.tencent.apps.valorant:id/edit_body", text="添加描述").set_text("要相信美好的事件即将发送")
        self.po.poco("com.tencent.apps.valorant:id/topic").click()
        self.po.poco("com.tencent.apps.valorant:id/option_layout").click()
        self.po.poco("com.tencent.apps.valorant:id/completed").click()

    def release_SP(self):
        # 发布视频
        self.po.poco("com.tencent.apps.valorant:id/bottom_title_center_btn").click()
        self.po.poco("com.tencent.apps.valorant:id/tv_local_type_video").click()
        self.po.poco("com.tencent.apps.valorant:id/tvCheck").click()
        self.po.poco("com.tencent.apps.valorant:id/tv_one_publish").click()
        self.po.poco("com.tencent.apps.valorant:id/root_container").click()
        time.sleep(5)
        self.po.poco("com.tencent.apps.valorant:id/btnNextStep").click()
        time.sleep(3)
        self.po.poco("com.tencent.apps.valorant:id/edit_title", text="添加标题可以让更多人看到哦").set_text("明天你好")
        self.po.poco("com.tencent.apps.valorant:id/edit_body", text="添加描述").set_text("要相信美好的事件即将发送")
        self.po.poco("com.tencent.apps.valorant:id/topic").click()
        self.po.poco("com.tencent.apps.valorant:id/option_layout").click()
        self.po.poco("com.tencent.apps.valorant:id/completed").click()

    def release_CWZ(self):
        # 发布纯文帖
        self.po.poco("com.tencent.apps.valorant:id/bottom_title_center_btn").click()
        self.po.poco("com.tencent.apps.valorant:id/ps_btn_text_edit").click()
        self.po.poco("com.tencent.apps.valorant:id/ed_input").set_text("su7")
        self.po.poco("com.tencent.apps.valorant:id/btn_generate_cover").click()
        self.po.poco("com.tencent.apps.valorant:id/tv_next_step").click()

    def click_to_pk(self):
        self.po.poco("com.tencent.apps.valorant:id/pk").click()
        self.po.poco("com.tencent.apps.valorant:id/tv_pk_title").set_text("谁是你们心中的完美皮肤")
        self.po.poco("android.widget.FrameLayout").child("android.widget.LinearLayout").offspring(
            "com.tencent.apps.valorant:id/qt_content").offspring(
            "com.tencent.apps.valorant:id/recyclerView_vote_picture").offspring(
            "com.tencent.apps.valorant:id/pk_1")[0].offspring("com.tencent.apps.valorant:id/tv_pk_text").set_text("塑水宗")
        self.po.poco("android.widget.FrameLayout").child("android.widget.LinearLayout").offspring(
            "com.tencent.apps.valorant:id/qt_content").offspring(
            "com.tencent.apps.valorant:id/recyclerView_vote_picture").offspring(
            "com.tencent.apps.valorant:id/pk_2")[0].offspring("com.tencent.apps.valorant:id/tv_pk_text").set_text("盖亚1.0")
        self.po.poco(text="完成").click()
        self.po.poco("com.tencent.apps.valorant:id/completed").click()

    def click_to_tp(self):
        # 进入投票
        self.po.poco("com.tencent.apps.valorant:id/vote").click()
        self.po.poco("com.tencent.apps.valorant:id/tv_vote_title").set_text("你们喜欢哪个英雄")
        self.po.poco("android.widget.FrameLayout").child("android.widget.LinearLayout").offspring(
            "com.tencent.apps.valorant:id/qt_content").offspring(
            "com.tencent.apps.valorant:id/recyclerView_vote_text").offspring(
            "com.tencent.apps.valorant:id/ll_vote_text_container")[0].child("android.widget.LinearLayout")[0].offspring(
            "com.tencent.apps.valorant:id/tv_vote_text").set_text("塑水宗")
        self.po.poco("android.widget.FrameLayout").child("android.widget.LinearLayout").offspring(
            "com.tencent.apps.valorant:id/qt_content").offspring(
            "com.tencent.apps.valorant:id/recyclerView_vote_text").offspring(
            "com.tencent.apps.valorant:id/ll_vote_text_container")[0].child("android.widget.LinearLayout")[1].offspring(
            "com.tencent.apps.valorant:id/tv_vote_text").set_text("盖亚1.0")
        self.po.poco(text="完成").click()
        self.po.poco("com.tencent.apps.valorant:id/completed").click()